home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat5 / auto_p.z / auto_p
Encoding:
Text File  |  1998-10-30  |  57.1 KB  |  1,387 lines

  1.  
  2.  
  3.  
  4. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      AUTO_P - Automatic Parallelization
  10.  
  11. TTTTOOOOPPPPIIIICCCC
  12.      This man page discusses automatic parallelization and how to achieve it
  13.      with the Silicon Graphics MIPSpro Automatic Parallelization Option. The
  14.      following topics are covered:
  15.  
  16.      _A_u_t_o_m_a_t_i_c _P_a_r_a_l_l_e_l_i_z_a_t_i_o_n _a_n_d _t_h_e _M_I_P_S_p_r_o _C_o_m_p_i_l_e_r_s
  17.  
  18.      _U_s_i_n_g _t_h_e _M_I_P_S_p_r_o _A_u_t_o_m_a_t_i_c _P_a_r_a_l_l_e_l_i_z_a_t_i_o_n _O_p_t_i_o_n
  19.  
  20.  
  21. AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzaaaattttiiiioooonnnn aaaannnndddd tttthhhheeee MMMMIIIIPPPPSSSSpppprrrroooo CCCCoooommmmppppiiiilllleeeerrrrssss
  22.      Parallelization is the process of analyzing sequential programs for
  23.      parallelism so that they may be restructured to run efficiently on
  24.      multiprocessor systems. The goal is to minimize the overall computation
  25.      time by distributing the computational work load among the available
  26.      processors. Parallelization can be automatic or manual.
  27.  
  28.      During automatic parallelization, the MIPSpro Automatic Parallelization
  29.      Option, hereafter called the auto-parallelizer, analyzes and structures
  30.      the program with little or no intervention by the developer. The auto-
  31.      parallelizer can automatically generate code that splits the processing
  32.      of loops among multiple processors. The alternative is manual
  33.      parallelization by which the developer performs the parallelization using
  34.      pragmas and other programming techniques. Manual parallelization is
  35.      discussed in the mp(3f) and mp(3c) man pages.
  36.  
  37.      Automatic parallelization begins with the determination of data
  38.      dependence of variables and arrays in loops. Data dependence can prevent
  39.      loops from being safely run in parallel because the final outcome of the
  40.      computation may vary depending on the order the various processors access
  41.      the variables and arrays. Data dependence and other obstacles to
  42.      parallelization are discussed in more detail in the next section.
  43.  
  44.      Once data dependences are resolved, a number of automatic parallelization
  45.      strategies can be employed. They can consist of the following:
  46.  
  47.           _L_o_o_p _i_n_t_e_r_c_h_a_n_g_e _o_f _n_e_s_t_e_d _l_o_o_p_s
  48.  
  49.           _S_c_a_l_a_r _e_x_p_a_n_s_i_o_n
  50.  
  51.           _L_o_o_p _d_i_s_t_r_i_b_u_t_i_o_n
  52.  
  53.           _A_u_t_o_m_a_t_i_c _s_y_n_c_h_r_o_n_i_z_a_t_i_o_n _o_f _D_O_A_C_R_O_S_S _l_o_o_p_s
  54.  
  55.           _I_n_t_r_a_p_r_o_c_e_d_u_r_a_l _a_r_r_a_y _p_r_i_v_a_t_i_z_a_t_i_o_n
  56.  
  57.      The 7.2 release of the MIPSpro compilers marks a major revision of the
  58.      auto-parallelizer. The new release incorporates automatic parallelization
  59.      into the other optimizations performed by the MIPSpro compilers. Previous
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  71.  
  72.  
  73.  
  74.      versions relied on preprocessors to provide source-to-source conversions
  75.      prior to compilation. This change provides several benefits to
  76.      developers:
  77.  
  78.      Automatic parallelization is integrated with optimizations for single
  79.      processors
  80.  
  81.      A set of options and pragmas consistent with the rest of the MIPSpro
  82.      compilers
  83.  
  84.      Support for C++
  85.  
  86.      Better run-time and compile-time performance
  87.  
  88.  
  89.  
  90. TTTThhhheeee MMMMIIIIPPPPSSSSpppprrrroooo AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzaaaattttiiiioooonnnn OOOOppppttttiiiioooonnnn
  91.      Developers exploit parallelism in programs to provide better performance
  92.      on multiprocessor systems. You do not need a multiprocessor system to use
  93.      th e automatic parallelizer. Although there is a slight performance loss
  94.      when a single-processor system runs multiprocessed code, you can use the
  95.      auto-parallelizer on any Silicon Graphics system to create and debug a
  96.      program.
  97.  
  98.      The automatic parallelizer is an optional software product that is used
  99.      as an extension to the following compilers:
  100.  
  101.           MIPSpro Fortran 77
  102.  
  103.           MIPSpro Fortran 90
  104.  
  105.           MIPSpro C
  106.  
  107.           MIPSpro C++
  108.  
  109.      It is controlled by flags inserted in the command lines that invoke the
  110.      supported compilers.
  111.  
  112.  
  113. UUUUssssiiiinnnngggg tttthhhheeee MMMMIIIIPPPPSSSSpppprrrroooo AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeerrrr
  114.      This section describes how to use the auto-parallelizer when you compile
  115.      and run programs with the MIPSpro compilers.
  116.  
  117.    UUUUssssiiiinnnngggg tttthhhheeee MMMMIIIIPPPPSSSSpppprrrroooo CCCCoooommmmppppiiiilllleeeerrrrssss ttttoooo PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeee PPPPrrrrooooggggrrrraaaammmmssss
  118.      You invoke the auto-parallelizer by using the ----ppppffffaaaa or ----ppppccccaaaa flags on the
  119.      command lines for the MIPSpro compilers. The syntax for compiling
  120.      programs with the auto-parallelizer is as follows:
  121.  
  122.      For Fortran 77 and Fortran 90 use ----ppppffffaaaa::::
  123.  
  124.      %%%%ffff77777777 _o_p_t_i_o_n_s ----ppppffffaaaa [{ lllliiiisssstttt | kkkkeeeeeeeepppp }] [ ----mmmmpppplllliiiisssstttt ] _f_i_l_e_n_a_m_e
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  137.  
  138.  
  139.  
  140.      %%%%ffff99990000 _o_p_t_i_o_n_s ----ppppffffaaaa [{ lllliiiisssstttt | kkkkeeeeeeeepppp }] [ ----mmmmpppplllliiiisssstttt ] _f_i_l_e_n_a_m_e
  141.  
  142.  
  143.      For C and C++ use -pca:
  144.  
  145.      %%%%cccccccc _o_p_t_i_o_n_s ----ppppccccaaaa [{ lllliiiisssstttt | kkkkeeeeeeeepppp }] [ ----mmmmpppplllliiiisssstttt ] _f_i_l_e_n_a_m_e
  146.  
  147.      %%%%CCCCCCCC _o_p_t_i_o_n_s ----ppppccccaaaa [{ lllliiiisssstttt | kkkkeeeeeeeepppp }] [ ----mmmmpppplllliiiisssstttt ] _f_i_l_e_n_a_m_e
  148.  
  149.      where _o_p_t_i_o_n_s are MIPSPro compiler command-line options. For details on
  150.      the other options see the documentation for your MIPSPro compiler.
  151.  
  152.      ----ppppffffaaaa and ----ppppccccaaaa
  153.  
  154.           Invoke the auto-parallelizer and enable any multiprocessing
  155.           directives.
  156.  
  157.      lllliiiisssstttt
  158.           Produce an annotated listing of the parts of the program that can
  159.           (and cannot) run in parallel on multiple processors. The listing
  160.           file has the suffix .l.
  161.  
  162.      kkkkeeeeeeeepppp
  163.           Generate the listing file (.l), and the transformed equivalent
  164.           program (.m), and creates an output file for use with WorkShop Pro
  165.           MPF (.anl).
  166.  
  167.      ----mmmmpppplllliiiisssstttt
  168.           Generate a transformed equivalent program in a .w2f.f file for
  169.           Fortran 77 or a .w2c.c file for C.
  170.  
  171.      ffffiiiilllleeeennnnaaaammmmeeee
  172.           The name of the file containing the source code.
  173.  
  174.      To use the automatic parallelizer with Fortran programs, add the ----ppppffffaaaa
  175.      flag to both the compile and link line. For C or C++, add the ----ppppccccaaaa flag.
  176.  
  177.      If you link separately, you must also add ----mmmmpppp to the link line. Previous
  178.      versions of the Power compilers had a large set of flags to control
  179.      optimization. The 7.2 version uses the same set of options as the rest of
  180.      the MIPSPro compilers.  So, for example, while in the older Power
  181.      compilers the option ----ppppffffaaaa,,,,----rrrr====0000 turned off roundoff changing
  182.      transformations in the pfa preprocessor, in the new compiler
  183.      ----OOOOPPPPTTTT::::rrrroooouuuunnnnddddooooffffffff====0000 turns off roundoff changing transformations in all phases
  184.      of the compiler.
  185.  
  186.      The ----ppppffffaaaa list option generates a .l file. The .l file lists the loops in
  187.      your code, indicating which were parallelized and which were not. If any
  188.      were not parallelized, it explains why not. The ----ppppffffaaaa kkkkeeeeeeeepppp option
  189.      generates a .l, a .m file and a .anl file that is used by the Workshop
  190.      ProMPF tool. The .m file is similar to the .w2f.f or .w2c.c file except
  191.      that the file is annotated with some information used by Workshop ProMPF
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  203.  
  204.  
  205.  
  206.      tool.
  207.  
  208.      The ----mmmmpppplllliiiisssstttt option will, in addition to compiling your program, generate
  209.      a .w2f.f file (for Fortran 77, .w2c.c file for C) that represents the
  210.      program after the automatic parallelization phase. These programs should
  211.      be readable and in most cases should be valid code suitable for
  212.      recompilation. The ----mmmmpppplllliiiisssstttt option can be used to see what portions of
  213.      your code were parallelized.
  214.  
  215.      For Fortran 90 and C++, automatic parallelization happens after the
  216.      source program has been converted into an internal representation. It is
  217.      not possible to regenerate Fortran 90 or C++ after parallelization.
  218.  
  219.      Examples:
  220.  
  221.      Analyzing a .l File %cat foo.f
  222.  
  223.      subroutine sub(arr,n)
  224.            real*8 arr(n)
  225.            do i=1,n
  226.              arr(i) = arr(i) + arr(i-1)
  227.            end do
  228.            do i=1,n
  229.              arr(i) = arr(i) + 7.0
  230.              call foo(a)
  231.            end do
  232.            do i=1,n
  233.              arr(i) = arr(i) + 7.0
  234.            end do
  235.            end
  236.  
  237.      %f77 -O3 -n32 -mips4 -pfa list foo.f -c.
  238.  
  239.      Here's the associated .l file
  240.  
  241.      Parallelization Log for Subprogram sub_ 3: Not Parallel
  242.  
  243.               Array dependence from arr on line 4 to arr on line 4.
  244.  
  245.      6: Not Parallel
  246.  
  247.               Call foo on line 8.
  248.  
  249.      10: PARALLEL (Auto) __mpdo_sub_1
  250.  
  251.      Example Analyzing a .w2f.f File
  252.  
  253.      %cat test.f
  254.  
  255.      subroutine trivial(a)
  256.  
  257.        real a(10000)
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  269.  
  270.  
  271.  
  272.        do i=1,10000
  273.          a(i) = 0.0
  274.        end do end
  275.  
  276.  
  277.      %f77 -O3 -n32 -mips4 -c -pfa -c -mplist test.f
  278.  
  279.  
  280.      We get both an object file, test.o, and a test.w2f.f file that contains
  281.      the following code
  282.  
  283.  
  284.      SUBROUTINE trivial(a)
  285.  
  286.        IMPLICIT NONE
  287.  
  288.        REAL*4 a(10000_8)
  289.  
  290.        INTEGER*4 i
  291.  
  292.      C$DOACROSS local(i), shared(a)
  293.  
  294.        DO i = 1, 10000, 1
  295.  
  296.          a(i) = 0.0
  297.  
  298.        END DO
  299.  
  300.        RETURN
  301.  
  302.      END ! trivial
  303.  
  304.  
  305. RRRRuuuunnnnnnnniiiinnnngggg YYYYoooouuuurrrr PPPPrrrrooooggggrrrraaaammmm
  306.      Invoke your program as if it were a sequential program. The same binary
  307.      can execute using different numbers of processors. By default, the
  308.      runtime will selec t how many processors to use based on the number of
  309.      processors in the machine. The developer can use the environment
  310.      variable, NNNNUUUUMMMM____TTTTHHHHRRRREEEEAAAADDDDSSSS,,,, to change the default to use an explicit number of
  311.      processors. In addition, the developer can have the number of processors
  312.      vary dynamically from loop to loop based on system load by setting the
  313.      environment variable MMMMPPPP____SSSSUUUUGGGGNNNNUUUUMMMMTTTTHHHHDDDD.... Refer to the mp(3f) and mp(3c) for
  314.      more details.
  315.  
  316.      Simply passing code through the auto-parallelizer does not always produce
  317.      s all the increased performance available. In the next chapter, we
  318.      discuss strategies for making effective use of the product when the
  319.      auto-parallelizer is not able to fully parallelize an application.
  320.  
  321.    AAAAnnnnaaaallllyyyyzzzziiiinnnngggg tttthhhheeee AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeerrrr''''ssss RRRReeeessssuuuullllttttssss
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  335.  
  336.  
  337.  
  338.      Running a program through the auto-parallelizer often results in
  339.      excellent parallel speedups, but there are cases that cannot be
  340.      automatically well parallelized. By understanding the listing files, you
  341.      can sometimes identify small problems that prevent a loop from running
  342.      safely in parallel. With a relatively small amount of work, you can
  343.      remove these data dependencies and dramatically improve the program's
  344.      performance.
  345.  
  346.      Hint:  When trying to find loops to run in parallel, focus your efforts
  347.      on the areas of the code that use the bulk of the run time. Spending time
  348.      trying to run a routine in parallel that uses only one percent of the run
  349.      time of the program cannot significantly improve the overall performance
  350.      of your program. To determine where your code spends its time, take an
  351.      execution profile of the program using the Speedshop performance tools.
  352.  
  353.      The auto-parallelizer provides several mechanisms to analyze what it did.
  354.  
  355.      For Fortran 77 and C programs, the ----mmmmpppplllliiiisssstttt the code after
  356.      parallelization. Manual parallelism directives are inserted on loops that
  357.      have been automatically parallelized. For details about these directives,
  358.      refer to Chapters 5-7, "Fortran Enhancements for Multiprocessors," of the
  359.      MIPSpro Fortran 77 Programmer's Guide", or Chapter 11, "Multiprocessing
  360.      C/C++ Compiler Directives," of the C Language Reference Manual.
  361.  
  362.      The output code in the .w2f.f or .w2c.c file should be readable and under
  363.      standable. The user can use it as a tool to gain insight into what the
  364.      auto-parallelizer did. The user can then use that insight to make changes
  365.      to the original source program.
  366.  
  367.      Note that the auto-parallelizer is not a source to source preprocessor,
  368.      but is instead an internal phase of the MIPSPro compilers. With a
  369.      preprocessor system, a post parallelization file would always be
  370.      generated and fed into the regular compiler. This is not the case with
  371.      the auto-parallelizer. Therefore, compiling a .w2f.f or .w2c.c file
  372.      through a MIPSPro compiler will not generate identical code to compiling
  373.      the original source through the MIPSPro auto-parallelizer. But, often the
  374.      two will be almost the same.
  375.  
  376.      The auto-parallelizer also provides a listing mechanism via the ----ppppffffaaaa or
  377.      ----ppppccccaaaa kkkkeeeeeeeepppp or ----ppppffffaaaa or ----ppppccccaaaa list option. This will cause the compiler to
  378.      generate a .l file. The .l file will list the original loops in the
  379.      program along with messages telling whether or not the loops were
  380.      parallelized. For loops that were not parallelized, an explanation will
  381.      be given.
  382.  
  383.  
  384.      Parallelization Failures With the Automatic Parallelizer
  385.  
  386.      This section discusses mistakes you can avoid and actions you can take to
  387.      enhance the performance of the auto-parallelizer. The auto-parallelizer
  388.      is not always able to parallelize programs effectively. This can be true
  389.      for a number of reason s, some of which you can address. There are three
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  401.  
  402.  
  403.  
  404.      broad categories of parallelization failure:
  405.  
  406.      The auto-parallelizer does not detect that a loop is safe to parallelize
  407.  
  408.      The auto-parallelizer chooses the wrong nested loop to make parallel
  409.  
  410.      The auto-parallelizer parallelizes a loop that would run more efficiently
  411.      sequentially
  412.  
  413.    FFFFaaaaiiiilllluuuurrrreeee ttttoooo RRRReeeeccccooooggggnnnniiiizzzzeeee SSSSaaaaffffeeee LLLLooooooooppppssss
  414.      We want the auto-parallelizer to recognize every loop that is safe to par
  415.      allelize. A loop is not safe if there is data dependence, so the
  416.      automatic parallelizer analyzes each loop in a sequential program to try
  417.      to prove it is safe. If it cannot prove a loop is safe, it does not do
  418.      the parallelization. A loop that contains any of the constructs described
  419.      in this section may not be proved safe. However, in many instances the
  420.      loop can be proved safe after minor changes. You should review your
  421.      program's .l file, to see if there are any of these constructs in your
  422.      code.
  423.  
  424.      Usually the failure to recognize a loop as safe is related to one or more
  425.      of the following practices:.
  426.  
  427.      Function Calls in Loops
  428.  
  429.      GO TO Statements in Loops
  430.  
  431.      Complicated Array Subscripts
  432.  
  433.      Conditionally Assigned Temporary Variables in Loops"
  434.  
  435.      Unanalyzable Pointer Usage in C/C++
  436.  
  437.    FFFFuuuunnnnccccttttiiiioooonnnn CCCCaaaallllllllssss iiiinnnn LLLLooooooooppppssss
  438.      By default, the auto-parallelizer does not parallelize a loop that
  439.      contains a function call because the function in one iteration may modify
  440.      or depend on data in other iterations of the loop. However, a couple of
  441.      tools can help with this problem.
  442.  
  443.      Interprocedural analysis, specified by the ----IIIIPPPPAAAA command-line option, can
  444.      provide the auto-parallelizer with enough additional information to
  445.      parallelize some loops that contain function calls. For more information
  446.      on interprocedural analysis, see the _M_I_P_S_p_r_o _C_o_m_p_i_l_i_n_g _a_n_d _P_e_r_f_o_r_m_a_n_c_e
  447.      _T_u_n_i_n_g _G_u_i_d_e.
  448.  
  449.      TTTThhhheeee CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT CCCCAAAALLLLLLLL Fortran assertion, discussed below allows
  450.      you to tell the auto-parallelizer to ignore function calls when analyzing
  451.      the specified loops.
  452.  
  453.    GGGGOOOO TTTTOOOO SSSSttttaaaatttteeeemmmmeeeennnnttttssss iiiinnnn LLLLooooooooppppssss
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  467.  
  468.  
  469.  
  470.      The use of GGGGOOOO TTTTOOOO statements in loops can cause two problems:
  471.  
  472.      Early exits from loops.
  473.           It is not possible to parallelize loops with early exits, either
  474.           automatically or manually.
  475.  
  476.      Unstructured control flows.
  477.           The auto-parallelizer attempts to convert unstructured control flows
  478.           in loops into structured constructs. If the auto-parallelizer cannot
  479.           restructure these control flows, your only alternatives are manual
  480.           parallelization or restructuring the code.
  481.  
  482.  
  483.    CCCCoooommmmpppplllliiiiccccaaaatttteeeedddd AAAArrrrrrrraaaayyyy SSSSuuuubbbbssssccccrrrriiiippppttttssss
  484.      There are several cases where array subscripts are too complicated to
  485.      permit parallelization.
  486.  
  487.  
  488.      IIIInnnnddddiiiirrrreeeecccctttt AAAArrrrrrrraaaayyyy RRRReeeeffffeeeerrrreeeennnncccceeeessss
  489.           The auto-parallelizer is not able to analyze indirect array
  490.           references. Consider the following Fortran example.
  491.  
  492.           do i= 1,n
  493.  
  494.             a(b(i)) ...
  495.  
  496.           end do
  497.  
  498.           This loop cannot be run safely in parallel if the indirect reference
  499.           b(i) is equal to the same value for different iterations of i. If
  500.           every element of array b is unique, the loop can safely be made
  501.           parallel. In such cases, use either manual methods or the CCCC****$$$$****
  502.           AAAASSSSSSSSEEEERRRRTTTT PPPPEEEERRRRMMMMUUUUTTTTAAAATTTTIIIIOOOONNNN Fortran directive discussed below, to achieve
  503.           parallelism.
  504.  
  505.  
  506.      UUUUnnnnaaaannnnaaaallllyyyyzzzzaaaabbbblllleeee SSSSuuuubbbbssssccccrrrriiiippppttttssss
  507.           The auto-parallelizer cannot parallelize loops containing arrays
  508.           with unanalyzable subscripts. In the following case, the auto-
  509.           parallelizer is not able to analyze the / in the array subscript and
  510.           cannot reorder the loop.
  511.  
  512.           do i = l,u,2
  513.  
  514.             a(i/2) = ... Changed to ().
  515.  
  516.           end do
  517.  
  518.  
  519.      HHHHiiiiddddddddeeeennnn KKKKnnnnoooowwwwlllleeeeddddggggeeee
  520.           In the following example there may be hidden knowledge about the
  521.           relationship between the variables m and n.
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  533.  
  534.  
  535.  
  536.           do i = 1,n
  537.  
  538.             a(i) = a(i+m) Changed to ().
  539.  
  540.           end do
  541.  
  542.           The loop can be run in parallel if m > n, because the arrays will
  543.           not overlap. However, because the auto-parallelizer does not know
  544.           the value of the variables, it cannot make the loop parallel.
  545.  
  546.  
  547.    CCCCoooonnnnddddiiiittttiiiioooonnnnaaaallllllllyyyy AAAAssssssssiiiiggggnnnneeeedddd TTTTeeeemmmmppppoooorrrraaaarrrryyyy VVVVaaaarrrriiiiaaaabbbblllleeeessss iiiinnnn LLLLooooooooppppssss
  548.      When parallelizing a loop, the auto-parallelizer often localizes
  549.      (privatizes) temporary scalar and array variables. Consider the following
  550.      example.
  551.  
  552.      do i = 1,n
  553.  
  554.        do j = 1,n
  555.  
  556.          tmp(j) = ...
  557.  
  558.        end do
  559.  
  560.        do j = 1,n
  561.  
  562.          a(j,i) = a(j,i) + tmp(j)
  563.  
  564.        end do
  565.  
  566.      end do
  567.  
  568.      The array tmp is used for local scratch space. To successfully
  569.      parallelize the outer (i) loop, each processor must be given a distinct,
  570.      private tmp array. In this example, the auto-parallelizer is able to
  571.      localize tmp and parallelize the loop.  The auto-parallelizer runs into
  572.      trouble when a conditionally assigned temporary variable might be used
  573.      outside of the loop, as in the following example.
  574.  
  575.      subroutine s1(a,b)
  576.  
  577.        common t
  578.  
  579.        ...
  580.  
  581.        do i = 1,n
  582.  
  583.          if (b(i)) then
  584.  
  585.            t = ...
  586.  
  587.            a(i) = a(i) + t
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  599.  
  600.  
  601.  
  602.          end if
  603.  
  604.        end do
  605.  
  606.        call s2()
  607.  
  608.  
  609.      If the loop were to be run in parallel, a problem would arise if the
  610.      value of t were used inside subroutine s2(). Which processor's private
  611.      copy of t should s2() use? If t were not conditionally assigned, the
  612.      answer would be the processor that executed iteration n. But t is
  613.      conditionally assigned and the auto-parallelizer cannot determine which
  614.      copy to use.
  615.  
  616.      The loop is inherently parallel if the conditionally assigned variable t
  617.      is localized. If the value of t is not used outside the loop, you should
  618.      replace t with a local variable. Unless t is a local variable, the auto-
  619.      parallelizer must assume that s2() might use it.
  620.  
  621.  
  622.    UUUUnnnnaaaannnnaaaallllyyyyzzzzaaaabbbblllleeee PPPPooooiiiinnnntttteeeerrrr UUUUssssaaaaggggeeee iiiinnnn CCCC////CCCC++++++++
  623.      The C and C++ languages have features that make them more difficult than
  624.      Fortran to automatically parallelize. Many of these features are related
  625.      to the use of pointers. The following practices involving pointers
  626.      interfere with the auto-parallelizer's effectiveness:
  627.  
  628.  
  629.      AAAArrrrbbbbiiiittttrrrraaaarrrryyyy PPPPooooiiiinnnntttteeeerrrr DDDDeeeerrrreeeeffffeeeerrrreeeennnncccceeeessss
  630.           The auto-parallelizer does not analyze arbitrary pointer
  631.           dereferences. The only pointers it analyzes are array references and
  632.           pointer dereferences that can be converted into array references.
  633.           The auto-parallelizer can subdivide the trees formed by
  634.           dereferencing arbitrary pointers and run the parts in parallel.
  635.           However, it cannot determine if the tree is really a directed graph
  636.           with an unsafe multiple reference. Therefore the parallelization is
  637.           not done.
  638.  
  639.  
  640.      AAAArrrrrrrraaaayyyyssss ooooffff AAAArrrrrrrraaaayyyyssss
  641.           Multidimensional arrays are sometimes implemented as arrays of
  642.           arrays. Consider this example:  double **p;
  643.  
  644.           for (int i = 0; i < n; i++)
  645.  
  646.  
  647.             for (int j = 0; j < n; j++)
  648.  
  649.               p[i][j] =  ...
  650.  
  651.           If p is a true multi-dimensional array, the outer loop can be run
  652.           safely in parallel. If two of the array pointers, p[2] and p[3] for
  653.           example, reference the same array, the loop must not be run in
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  665.  
  666.  
  667.  
  668.           parallel. Although this duplicate reference is unlikely, the auto-
  669.           parallelizer cannot prove it doesn't exist. You can avoid this
  670.           problem by always using true arrays. To parallelize the code
  671.           fragment above, rewrite it as follows:
  672.  
  673.           double p[n][n];
  674.  
  675.           for (int i = 0; i < n; i++)
  676.  
  677.  
  678.             for (int j = 0; j < n; j++)
  679.  
  680.               p[i][j] = ...
  681.  
  682.           Note:  Although ANSI C does not allow variable-sized multi-
  683.           dimensional arrays, there is a proposal to allow them in the next
  684.           standard. The MIPSPro 7.2 auto-parallelizer already implements this
  685.           proposal.
  686.  
  687.  
  688.      LLLLooooooooppppssss BBBBoooouuuunnnnddddeeeedddd bbbbyyyy PPPPooooiiiinnnntttteeeerrrr CCCCoooommmmppppaaaarrrriiiissssoooonnnnssss
  689.  
  690.           The auto-parallelizer reorders only those loops in which the number
  691.           of it erations can be exactly determined. In Fortran programs this
  692.           is rarely a problem, but in C and C++ subtle issues relating to
  693.           overflow and unsigned arithmetic can come to play. One consequence
  694.           of this is that loops should not be bounded by pointer comparisons
  695.           such as
  696.  
  697.           int* pl, pu;
  698.  
  699.           for (int *p = pl; p != pu; p++)
  700.  
  701.           This loop cannot be made parallel, and compiling it will result in a
  702.           .l file entry stating the bound cannot be standardized. To avoid
  703.           this result, restructure the loop to be of the form
  704.  
  705.           int lb, ub;
  706.  
  707.           for (int i = lb; i <= ub; i++)
  708.  
  709.  
  710.      AAAAlllliiiiaaaasssseeeedddd PPPPaaaarrrraaaammmmeeeetttteeeerrrr IIIInnnnffffoooorrrrmmmmaaaattttiiiioooonnnn
  711.           Perhaps the most frequent impediment to parallelizing C and C++ is
  712.           aliased information. Although Fortran guarantees that multiple
  713.           parameters to a subroutine are not aliased to each other, C and C++
  714.           do not. Consider the following example:
  715.  
  716.           void sub(double *a, double *b,n) {
  717.  
  718.             for (int i = 0; i < n; i++)
  719.  
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  731.  
  732.  
  733.  
  734.               a[i] = b[i];
  735.  
  736.           This loop can be parallelized only if arrays a and b do not overlap.
  737.           With the option -OPT:alias=restrict, you can assure the auto-
  738.           parallelizer that the arrays do not overlap. This assurance permits
  739.           the auto-parallelizer to proceed with the parallelization. See the
  740.           MIPSpro Compiling and Performance Tuning Guide for details about
  741.           this option.
  742.  
  743.  
  744.      IIIInnnnccccoooorrrrrrrreeeeccccttttllllyyyy PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeedddd NNNNeeeesssstttteeeedddd LLLLooooooooppppssss
  745.           The auto-parallelizer parallelizes a loop by distributing its
  746.           iterations among the available processors.
  747.  
  748.           Because the resulting performance is usually better, the auto-
  749.           parallelizer tries to parallelize the outermost loop.
  750.  
  751.           If it cannot do so, probably for one of the reasons mentioned in the
  752.           previous section, it tries to interchange the outermost loop with an
  753.           inner one that it can parallelize.
  754.  
  755.           Example Nested Loops
  756.  
  757.           do i = 1,n
  758.  
  759.             do j = 1,n
  760.  
  761.               ...
  762.  
  763.             end do
  764.  
  765.           end do
  766.  
  767.           Even when most of your program is parallelized, it is possible that
  768.           the wrong loop is parallelized. Given a nest of loops, the auto-
  769.           parallelizer will only parallelize one of the loops in the nest. In
  770.           general, it is better to parallelize outer loops rather than inner
  771.           ones.
  772.  
  773.           The auto-parallelizer will try to either parallelize the outer loop
  774.           or in terchange the parallel loop so that it will be outermost, but
  775.           sometimes it is not possible. For any of the reasons mentioned in
  776.           the previous section, the auto-parallelizer might be able to
  777.           parallelize an inner loop but not the outer one. Even if this
  778.           results in most of your code being parallelized, it might be
  779.           advantageous to modify your code so that the outer loop is
  780.           parallelized.
  781.  
  782.           It is better to parallelize loops that do not have very small trip
  783.           counts.  Consider the following example.
  784.  
  785.           do i = 1,m
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  797.  
  798.  
  799.  
  800.             do j = 1,n
  801.  
  802.           The auto-parallelizer may decide to parallelize the i loop, but if m
  803.           is v ery small, it would be better to interchange the j loop to be
  804.           outermost and then parallelize it. The auto-parallelizer might not
  805.           have any way to know that m is small. In such cases, the user can
  806.           either use the CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR
  807.  
  808.           directives discussed in the next section to tell the auto-
  809.           parallelizer that it is better to parallelize the j loop, or the
  810.           user can use manual parallelism directives.
  811.  
  812.           Because of memory hierarchies, performance can be improved if the
  813.           same processors access the same data in all parallel loop nests.
  814.           Consider the following two examples.
  815.  
  816.           Example   Inefficient Loop
  817.  
  818.           do i = 1,n
  819.  
  820.             ...a(i)
  821.  
  822.           end do
  823.  
  824.           do i = n,1
  825.  
  826.             ...a(i)...
  827.  
  828.           end do
  829.  
  830.           Assume that there are p processors. In the first loop, the first
  831.           processor will access the first n/p elements of a, the second
  832.           processor will access the next n/p and so on. In the second loop,
  833.           the first processor will access the last n/p elements of a. Assuming
  834.           n is not too large, those elements will be in the cache of the a
  835.           different processor. Accessing data that is in some other
  836.           processor's cache can be very expensive. This example might run much
  837.           more efficiently if we reverse the direction of one of the loops.
  838.  
  839.           Example   Efficient Loop
  840.  
  841.           do i = 1,n
  842.  
  843.             do j = 1,n
  844.  
  845.               a(i,j) = b(j,i) + ...
  846.  
  847.             end do
  848.  
  849.           end do
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  863.  
  864.  
  865.  
  866.           do i = 1,n
  867.  
  868.             do j = 1,n
  869.  
  870.               b(i,j) = a(j,i) + ...
  871.  
  872.             end do
  873.  
  874.           end do
  875.  
  876.           In this second example, the auto-parallelizer might chose to
  877.           parallelize the outer loop in both nests. This means that in the
  878.           first loop the first processor is accessing the first n/p rows of a
  879.           and the first n/p columns of b, while in the second loop the first
  880.           processor is accessing the first n/p columns of a and the first n/p
  881.           rows of b. This example will run much more efficiently if we
  882.           parallelize the i loop in one nest and the j loop in the other. The
  883.           user can add the prefer directives described in the next section to
  884.           solve this problem.
  885.  
  886.  
  887. UUUUnnnnnnnneeeecccceeeessssssssaaaarrrriiiillllyyyy PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeedddd LLLLooooooooppppssss
  888.      The auto-parallelizer may parallelize loops that would run better sequent
  889.      ially. While this is usually not a disaster, it can cause unnecessary
  890.      overhead. There is a certain overhead to running loops in parallel. If,
  891.      for example, a loop has a small number of iterations, it is faster to
  892.      execute the loop sequentially. When bounds are unknown (and even
  893.      sometimes when they are known), the auto-parallelizer parallelizes loops
  894.      conditionally. In other words, code is generated for both a parallel and
  895.      sequential version of the loop. The parallel version is executed only
  896.      when the auto-parallelizer thinks that there is sufficient work for it to
  897.      be worthwhile to execute the loop in parallel. This estimate depends on
  898.      the iteration count, what code is inside the loop body, how many
  899.      processors are available and the auto-parallelizer estimate for the
  900.      overhead cost to invoke a parallel loop. This user can control the
  901.      compiler's estimate for the invocation overhead using the option
  902.      ----LLLLNNNNOOOO::::ppppaaaarrrraaaalllllllleeeellll____oooovvvveeeerrrrhhhheeeeaaaadddd====nnnn.... The default value for n will vary on different
  903.      systems, but typical values are in the low thousands.
  904.  
  905.      By generating two versions of the loop, we avoid going parallel in small
  906.      trip count cases, but versioning does incur an overhead to do the dynamic
  907.      check. The user can use the DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR assertions to insure that a loop
  908.      goes parallel or sequential without incurring a run-time test.
  909.  
  910.      Nested parallelism is not supported. Consider the following case:
  911.  
  912.      subroutine caller
  913.  
  914.        do i
  915.  
  916.          call sub
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  929.  
  930.  
  931.  
  932.        end do
  933.  
  934.      subroutine sub
  935.  
  936.        ...
  937.  
  938.        do i
  939.  
  940.          ..
  941.  
  942.        end do
  943.  
  944.      end
  945.  
  946.      Suppose that the first loop is parallelized. It is not possible to
  947.      execute the loop inside sub in parallel whenever sub is called by caller.
  948.      Thus the auto-parallelizer must generate a test for every parallel loop
  949.      that checks whether the loop is being invoked from another parallel loop
  950.      or region. While this check is not very expensive, in some cases it can
  951.      add to overhead. If the user knows that sub is always called from caller,
  952.      the user can use the prefer directives to force the loop in sub to go
  953.      sequential.
  954.  
  955.  
  956. AAAAssssssssiiiissssttttiiiinnnngggg tttthhhheeee SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeerrrr
  957.      This section discusses actions you can take to enhance the performance of
  958.      the auto-parallelizer.
  959.  
  960.    AAAAssssssssiiiissssttttiiiinnnngggg tttthhhheeee AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzeeeerrrr
  961.      There are circumstances that interfere with the auto-parallelizer's
  962.      ability to optimize programs. As shown in _P_a_r_a_l_l_e_l_i_z_a_t_i_o_n _F_a_i_l_u_r_e_s _W_i_t_h
  963.      _t_h_e _A_u_t_o_m_a_t_i_c _P_a_r_a_l_l_e_l_i_z_e_r, problems are sometimes caused by coding
  964.      practices. Other times, the auto-parallelizer does not have enough
  965.      information to make good parallelization decisions. You can pursue three
  966.      strategies to attack these problems and achieve better results with the
  967.      auto-parallelizer.
  968.  
  969.      The first approach is to modify your code to avoid coding practices that
  970.      the auto-parallelizer cannot analyze well.
  971.  
  972.      The second strategy is to assist the auto-parallelizer with the manual
  973.      parallelization directives described in the MIPSpro Compiling and
  974.      Performance Tuning Guide. The auto-parallelizer is designed to recognize
  975.      and coexist with manual parallelism. You can use manual directives with
  976.      some loop nests, while leaving others to the auto-parallelizer. This
  977.      approach has both positive and negative aspects.
  978.  
  979.      On the positive side, the manual parallelism directives are well defined
  980.      and deterministic. If you use a manual directive, the specified loop will
  981.      run in parallel.
  982.  
  983.      Note:  This last statement assumes that the trip count is greater than
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  995.  
  996.  
  997.  
  998.      one and that the specified loop is not nested in another parallel loop.
  999.  
  1000.      On the negative side, you must carefully analyze the code to determine
  1001.      that parallelism is safe. Also, you must mark all variables that need to
  1002.      be localized.
  1003.  
  1004.      The third alternative is to use the automatic parallelization directives
  1005.      and assertions to give the auto-parallelizer more information about your
  1006.      code. The automatic directives and assertions are described in _D_i_r_e_c_t_i_v_e_s
  1007.      _a_n_d _A_s_s_e_r_t_i_o_n_s _f_o_r _A_u_t_o_m_a_t_i_c _P_a_r_a_l_l_e_l_i_z_a_t_i_o_n. Like the manual directives,
  1008.      they have positive and negative features:
  1009.  
  1010.      On the positive side, automatic directives and assertions are easier to
  1011.      use and they allow you to express the information you know without your
  1012.      having to be certain that all the conditions for parallelization are met.
  1013.  
  1014.      On the negative side, they are hints and thus do not impose parallelism.
  1015.      In addition, as with the manual directives, you must ensure that you are
  1016.      using them legally. Because they require less information than the manual
  1017.      directives, automatic directives and assertions can have subtle meanings.
  1018.  
  1019.    DDDDiiiirrrreeeeccccttttiiiivvvveeeessss aaaannnndddd AAAAsssssssseeeerrrrttttiiiioooonnnnssss ffffoooorrrr AAAAuuuuttttoooommmmaaaattttiiiicccc PPPPaaaarrrraaaalllllllleeeelllliiiizzzzaaaattttiiiioooonnnn
  1020.      Directives enable, disable, or modify features of the auto-parallelizer.
  1021.      Assertions assist the auto-parallelizer by providing it with additional
  1022.      information about the source program. The automatic directives and
  1023.      assertions do not impose parallelism; they give hints and assertions to
  1024.      the auto-parallelizer in order to assist it in paralleling the that the
  1025.      right loops. To invoke a directive or assertion, include it in the input
  1026.      file.  Listed below are the Fortran directives and assertions for the
  1027.      auto-parallelizer.
  1028.  
  1029.  
  1030.      CCCC****$$$$**** NNNNOOOO CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE
  1031.           Do not parallelize either a subroutine or file.
  1032.  
  1033.      CCCC****$$$$**** CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE
  1034.           Not used. (See below.)
  1035.  
  1036.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT))))
  1037.           Ignore perceived dependences between two references to the same
  1038.           array when parallelizing.
  1039.  
  1040.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((SSSSEEEERRRRIIIIAAAALLLL))))
  1041.           Do not parallelize the following loop.
  1042.  
  1043.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT CCCCAAAALLLLLLLL
  1044.           Ignore subroutine calls when parallelizing.
  1045.  
  1046.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT PPPPEEEERRRRMMMMUUUUTTTTAAAATTTTIIIIOOOONNNN ((((aaaarrrrrrrraaaayyyy____nnnnaaaammmmeeee))))
  1047.           Array array_name is a permutation array.
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  1061.  
  1062.  
  1063.  
  1064.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT))))
  1065.           Parallelize the following loop if it is safe.
  1066.  
  1067.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((SSSSEEEERRRRIIIIAAAALLLL))))
  1068.           Do not parallelize the following loop.
  1069.  
  1070.           Note:  The general compiler option ----LLLLNNNNOOOO::::iiiiggggnnnnoooorrrreeee____pppprrrraaaaggggmmmmaaaassss causes the
  1071.           auto-parallelizer to ignore all of these directives and assertions.
  1072.  
  1073.      CCCC****$$$$**** NNNNOOOO CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE
  1074.           The CCCC****$$$$**** NNNNOOOO CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE directive prevents parallelization. Its
  1075.           effect depends on where it is placed.
  1076.  
  1077.           When placed inside a subroutine, the directive prevents the
  1078.           parallelization of the subroutine. In the following example, SUB1()
  1079.           is not parallelized.  Example:
  1080.  
  1081.                  SUBROUTINE SUB1
  1082.  
  1083.           C*$* NO CONCURRENTIZE
  1084.  
  1085.                    ...
  1086.  
  1087.                  END
  1088.  
  1089.           When placed outside of a subroutine, CCCC****$$$$**** NNNNOOOO CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE prevents
  1090.           the parallelization of all the subroutines in the file. The
  1091.           subroutines SUB2() and SUB3() are not parallelized in the next
  1092.           example.  Example:
  1093.  
  1094.                  SUBROUTINE SUB2
  1095.  
  1096.                    ...
  1097.  
  1098.                  END
  1099.  
  1100.           C*$* NO CONCURRENTIZE
  1101.  
  1102.                  SUBROUTINE SUB3
  1103.  
  1104.                    ...
  1105.  
  1106.                  END
  1107.  
  1108.           The CCCC****$$$$**** NNNNOOOO CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE directive is valid only when the ----ppppffffaaaa or
  1109.           ----ppppccccaaaa command-line option is used.
  1110.  
  1111.  
  1112.      CCCC****$$$$**** CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTTIIIIZZZZEEEE
  1113.           The C*$* CONCURRENTIZE directive exists only to maintain backwards
  1114.           compatibility, and its use is discouraged. Using the ----ppppffffaaaa or ----ppppccccaaaa
  1115.           option replaces using this directive.
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  1127.  
  1128.  
  1129.  
  1130.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT))))
  1131.           CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT)))) says that when analyzing the loop
  1132.           immediately following this assertion, the auto-parallelizer should
  1133.           ignore any perceived dependences between two references to the same
  1134.           array. The following example is a correct use of the assertion when
  1135.           M > N.
  1136.  
  1137.           Example:
  1138.  
  1139.           C*$* ASSERT DO (CONCURRENT)
  1140.  
  1141.                  DO I = 1, N
  1142.  
  1143.                    A(I) = A(I+M)
  1144.  
  1145.           This assertion is usually used to help the auto-parallelizer with
  1146.           loops that have indirect array references. There are other facts to
  1147.           be aware of when using this assertion.
  1148.  
  1149.           If multiple loops in a nest can be parallelized, CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO
  1150.           ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT)))) causes the auto-parallelizer to prefer the loop
  1151.           immediately following the assertion.  The assertion does not affect
  1152.           how the auto-parallelizer analyzes CALL statements and dependences
  1153.           between two potentially aliased pointers.
  1154.  
  1155.           Note:  If there are real dependences between array references, CCCC****$$$$****
  1156.           AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT)))) may cause the auto-parallelizer to generate
  1157.           incorrect code.
  1158.  
  1159.  
  1160.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((SSSSEEEERRRRIIIIAAAALLLL))))
  1161.           CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO ((((SSSSEEEERRRRIIIIAAAALLLL)))) instructs the auto-parallelizer to not
  1162.           parallelize the loop following the assertion.
  1163.  
  1164.  
  1165.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT CCCCAAAALLLLLLLL
  1166.           The CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT CCCCAAAALLLLLLLL assertion tells the auto-
  1167.           parallelizer to ignore subroutine calls contained in a loop when
  1168.           deciding if that loop is parallel. The assertion applies to the loop
  1169.           that immediately follows it and to all loops nested inside that
  1170.           loop. The auto-parallelizer ignores subroutine FRED() when it
  1171.           analyzes the following loop.
  1172.  
  1173.           C*$* ASSERT CONCURRENT CALL
  1174.  
  1175.                  DO I = 1, N
  1176.  
  1177.                    CALL FRED
  1178.  
  1179.                    ...
  1180.  
  1181.                  END DO
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  1193.  
  1194.  
  1195.  
  1196.                  SUBROUTINE FRED
  1197.  
  1198.                    ...
  1199.  
  1200.                  END
  1201.  
  1202.  
  1203.           To prevent incorrect parallelization, you must make sure the
  1204.           following conditions are met when using CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT CCCCAAAALLLLLLLL::::
  1205.  
  1206.           A subroutine cannot read from a location inside the loop that is
  1207.           written to during another iteration. This rule does not apply to a
  1208.           location that is a local variable declared inside the subroutine.
  1209.  
  1210.           A subroutine cannot write to a location inside the loop that is read
  1211.           from during another iteration. This rule does not apply to a
  1212.           location that is a local variable declared inside the subroutine.
  1213.  
  1214.           The following code shows an illegal use of the assertion. Subroutine
  1215.           FRED() writes to variable T which is also read from by WILMA()
  1216.           during other iterations.
  1217.  
  1218.           C*$* ASSERT CONCURRENT CALL
  1219.  
  1220.                  DO I = 1,M
  1221.  
  1222.                    CALL FRED(B, I, T)
  1223.  
  1224.                    CALL WILMA(A, I, T)
  1225.  
  1226.                  END DO
  1227.  
  1228.                  SUBROUTINE FRED(B, I, T)
  1229.  
  1230.                    REAL B(*)
  1231.  
  1232.                    T = B(I)
  1233.  
  1234.                  END
  1235.  
  1236.                  SUBROUTINE WILMA(A, I, T)
  1237.  
  1238.                    REAL A(*)
  1239.  
  1240.                    A(I) = T
  1241.  
  1242.                  END
  1243.  
  1244.  
  1245.           By localizing the variable T, you could manually parallelize the
  1246.           above example safely. But, the auto-parallelizer does not know to
  1247.           localize T, and it illegally parallelizes the loop because of the
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  1259.  
  1260.  
  1261.  
  1262.           assertion.
  1263.  
  1264.  
  1265.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT PPPPEEEERRRRMMMMUUUUTTTTAAAATTTTIIIIOOOONNNN ((((aaaarrrrrrrraaaayyyy____nnnnaaaammmmeeee))))
  1266.           CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT PPPPEEEERRRRMMMMUUUUTTTTAAAATTTTIIIIOOOONNNN tells the auto-parallelizer that array_name
  1267.           is a permutation array: every element of the array has a distinct
  1268.           value. Array B is asserted to be a permutation array in this
  1269.           example.
  1270.  
  1271.           Example:
  1272.  
  1273.           C*$* ASSERT PERMUTATION (B)
  1274.  
  1275.                  DO I = 1, N
  1276.  
  1277.                    A(B(I)) = ...
  1278.  
  1279.                  END DO
  1280.  
  1281.  
  1282.           As shown in the previous example, you can use this assertion to
  1283.           parallelize loops that use arrays for indirect addressing. Without
  1284.           this assertion, the auto-parallelizer is not able to determine that
  1285.           the array elements used as indexes are distinct.
  1286.  
  1287.           Note:  The assertion does not require the permutation array to be
  1288.           dense.
  1289.  
  1290.  
  1291.      CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT))))
  1292.           CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT)))) says that the auto-parallelizer
  1293.           should parallelize the loop immediately following the assertion, if
  1294.           it is safe to do so. The following code encourages the auto-
  1295.           parallelizer to run the I loop in parallel.
  1296.  
  1297.           C*$*ASSERT DO PREFER (CONCURRENT)
  1298.  
  1299.                  DO I = 1, M
  1300.  
  1301.                    DO J = 1, N
  1302.  
  1303.                      A(I,J) = B(I,J)
  1304.  
  1305.                    END DO
  1306.  
  1307.                    ...
  1308.  
  1309.                  END DO
  1310.  
  1311.           When dealing with nested loops, follow these guidelines:
  1312.  
  1313.           If the loop specified by this assertion is safe to parallelize, the
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. AAAAUUUUTTTTOOOO____PPPP((((5555))))                                                            AAAAUUUUTTTTOOOO____PPPP((((5555))))
  1325.  
  1326.  
  1327.  
  1328.           auto-parallelizer chooses it to parallelize, even if other loops in
  1329.           the nest are safe.
  1330.  
  1331.           If the specified loop is not safe, the auto-parallelizer chooses
  1332.           another loop that is safe, usually the outermost.
  1333.  
  1334.           This assertion can be applied to more than one loop in a nest. In
  1335.           this case, the auto-parallelizer uses its heuristics to choose one
  1336.           of the specified loops.
  1337.  
  1338.  
  1339.           Note: CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((CCCCOOOONNNNCCCCUUUURRRRRRRREEEENNNNTTTT)))) is always safe to use. The
  1340.           auto-parallelizer will not illegally parallelize a loop because of
  1341.           this assertion.
  1342.  
  1343.           CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((SSSSEEEERRRRIIIIAAAALLLL))))
  1344.  
  1345.           The CCCC****$$$$**** AAAASSSSSSSSEEEERRRRTTTT DDDDOOOO PPPPRRRREEEEFFFFEEEERRRR ((((SSSSEEEERRRRIIIIAAAALLLL)))) assertion requests the auto-
  1346.           parallelizer not to parallelize the loop that immediately follows.
  1347.           In the following case, the assertion requests that the J loop be run
  1348.           serially.
  1349.  
  1350.                  DO I = 1, M
  1351.  
  1352.           C*$*ASSERT DO PREFER (SERIAL)
  1353.  
  1354.                    DO J = 1, N
  1355.  
  1356.                      A(I,J) = B(I,J)
  1357.  
  1358.                    END DO
  1359.  
  1360.                    ...
  1361.  
  1362.                  END DO
  1363.  
  1364.           Using C*$* ASSERT DO PREFER (SERIAL)
  1365.  
  1366.  
  1367.           The assertion applies only to the loop directly after the assertion.
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.